#include <bits/stdc++.h>

#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 2000010;

int n, k, a[maxn], ok;
vector<int> e[maxn];

namespace sub {
  void dfs(int u, int fa, int len, int cnt) {
    len++, cnt += a[u];
    if (len == k) ok &= (cnt == 1);
    for (int v : e[u]) if (v != fa) dfs(v, u, len, cnt);
  }

  bool check() {
    ok = 1;
    rep (i, 1, n) dfs(i, 0, 0, 0);
    return ok;
  }

  void work() {
    int ans = 0;
    rep (S, 0, (1 << n) - 1) {
      rep (i, 1, n) a[i] = (S >> (i - 1) & 1);
      if (check()) ans++;
    }
    if (!ans) cout << "NO\n" << ans << '\n';
    else cout << "YES\n" << ans << '\n';
  }
}

int main() {
  freopen("life.in", "r", stdin);
  freopen("life.out", "w", stdout);
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> k;
  rep (i, 1, n - 1) {
    int u, v;
    cin >> u >> v;
    e[u].emplace_back(v);
    e[v].emplace_back(u);
  }
  if (n <= 18) return sub::work(), 0;
  cout << "YES\n" << k << '\n';
}